<template>
	<view class="subsidy-pages">
		<template v-if="list.length>0">
			<view class="info-item" v-for="item in list" :key="item.id">
				<view class="name">{{item.name}}</view>
				<view class="phone">{{item.phone}}</view>
			</view>
		</template>
		<view v-if="more==false&&list.length==0" class="empty">暂无数据</view>
		<view v-else-if="more==false&&list.length>0" class="empty">没有更多了</view>
	</view>
</template>

<script>
	import {
		isMore
	} from '@/util/util.js'
	import {
		getEnjoyEnterprises
	} from '@/api/job_hunting.js';
	export default {
		data() {
			return {
				list: [],
				conf: {
					page: 1,
					limit: 10
				},
				more: true,
				keyWord: ''
			}
		},
		methods: {
			refresh() {
				this.conf.page = 1
				this.more = true
				this.getList(true);
			},
			getList(refresh = false) {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getEnjoyEnterprises({
					page: this.conf.page,
					limit: this.conf.limit,
					name: this.keyWord,
					eid: this.id
				}).then((res) => {
					let list = res.list || [];
					if (refresh) {
						this.list = list;
					} else {
						this.list = [...this.list, ...list]
					}
					this.more = isMore(this.conf.page, this.conf.limit, res.count)
				})
			}
		},
		onReachBottom() {
			if (this.more) {
				this.conf.page++;
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				this.getList();
			}
		},
		onLoad(e) {
			this.id = e.id
			this.getList(true)
		}
	}
</script>

<style lang="scss" scoped>
	.subsidy-pages {
		padding: 30rpx;

		.info-item {
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 30rpx;
			background-color: #fff;
			border-radius: 20rpx;
			margin-bottom: 30rpx;

			.name {
				font-size: 30rpx;
			}

			.phone {
				font-size: 28rpx;
				color: #767676;
			}
		}
	}
</style>